#include<stdio.h>
#include<stdlib.h>
#include<conio.h>

int main()
{	
	int i,j;
	int f=0,k=0;
	int x=10,y=5;
	char input;
	int ny=5;
	int score=0;
	int w=20;//初始化
	
	while(1)
	{
		system("cls");//
		
		if(k==0)
		{
			for(i=0;i<=ny;i++)
					printf(" ");
			printf("#");
		}
		else
		{
			ny = rand() % w+2;
			k=0;
		}//靶子

		if(f==0)
		{
			for(i=0;i<=x;i++)
				printf("\n");
		}
		else
		{
			for(i=0;i<=x;i++)
			{
				for(j=0;j<=y;j++)
					printf(" ");
				printf("  |\n");
			}
			if(y+2==ny)
			{
				k=1;
				score=score+1;
			}
			f=0;
		}//开火
		
        for(j=0;j<=y;j++)
			printf(" ");
		printf("  *\n");
		for(j=0;j<=y;j++)
			printf(" ");
		printf("*****\n");
		for(j=0;j<=y;j++)
			printf(" ");
		printf(" * *\n");//飞机
		
		if(kbhit())										
		{
			input=getch();
			if(input=='w')
				x--;
			if(input=='s')
				x++;
			if(input=='a')
				y--;
			if(input=='d')
				y++;
			if(input==' ')
				f=1;
		}//输入
		
		printf("score:%d\n", score);
	}
	return 0;
}